package organizer;

import java.util.Comparator;

/**
 * Compares files by content and then by name.
 * @author dawong
 */
public class MetadataComparator implements Comparator<IFileMetadata> {

    public int compare(IFileMetadata o1, IFileMetadata o2) {
        int c = 0;
        long diff = o1.getLength() - o2.getLength();
        if (diff < 0)
            c = -1;
        else if (diff > 0)
            c = 1;
        if (c == 0) {
            c = o1.getPath().compareTo(o2.getPath());
        }
        return c;
    }
    
}
